#ifndef DWM_MAINSERVER_H
#define DWM_MAINSERVER_H 1


#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
#include <string>

#include "userconnectionmanager.h"

#include "logging.h"

using boost::asio::ip::tcp;


//*******************************
class mainServer : LoggingService
{

  public:
    explicit mainServer(const std::string& address, int port);

    ~mainServer();

    void run();

    void stop();

  private:


    void begin_listen(int index);

    // accepting new clients

    void handle_accept(const boost::system::error_code &e, boost::shared_ptr<tcp::socket> socket, int index);

    // closing down the server
    void handle_stop();


    // use this for async sockets
    boost::asio::io_service m_io_service;

    // boost acceptor for tcpip connections
    tcp::acceptor* m_acceptor[2];
    std::string m_connection_name[2];

    UserConnectionManager m_mgr;



//    UserConnection * m_current_connection;



};









#endif
